package com.es.hr.baoxiaoShenpi;

import java.lang.reflect.Field;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import com.es.business.area.AreaBean;
import com.es.business.area.AreaBiz;
import com.es.business.city.CityBean;
import com.es.business.city.CityBiz;
import com.es.business.citys.CitysBean;
import com.es.business.citys.CitysBiz;
import com.es.business.province.ProvinceBean;
import com.es.business.province.ProvinceBiz;
import com.es.common.CommonBean;
import com.es.common.CommonBiz;
import com.es.hr.baoxiao.BaoxiaoBean;
import com.es.hr.baoxiao.BaoxiaoBiz;
import com.es.hr.emp.EmpInfoBean;
import com.es.main.LoginUserBeen;
import com.es.util.page.PageBean;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ActionSupport;

public class SearchCTMBaoxiaoInitAction extends ActionSupport
implements ServletRequestAware{
	 HttpServletRequest request;

	public void setServletRequest(HttpServletRequest paramHttpServletRequest) {
		// TODO Auto-generated method stub
		this.request = paramHttpServletRequest;
	}
	
	public String execute() throws Exception{
		String result = "";
		String message = "";
		BaoxiaoShenpiBiz baoxiaoShenpiBiz = new BaoxiaoShenpiBiz();
		BaoxiaoBiz baoxiaoBiz = new BaoxiaoBiz();
		
		LoginUserBeen userLogin = (LoginUserBeen)request.getSession().getAttribute("loginuser");
		String role = userLogin.getLoginRole();
		
		Date date = new Date();
		int year = date.getYear() + 1900;
		int mouth = date.getMonth() + 1;
		int day = date.getDate();
		
		String syear = new Integer(year).toString();
		String smouth = new Integer(mouth).toString();
		if(smouth.length() < 2) smouth = "0" + smouth;
		String sday = new Integer(day).toString();
		if(sday.length() < 2) sday = "0" + sday;
		
		String baoxiao_date = syear + "-" + smouth + "-" + sday;
		this.request.setAttribute("baoxiaoStateList", new CommonBiz().getCommonByType("baoxiaostate"));
		BaoxiaoBean bean = baoxiaoBiz.getBaoxiaoBaseInfoFromEmp(userLogin.getLoginId());
		CommonBean shiyebu = new CommonBiz().getCommonByTypeAndCode("shiyebu", "ITMall");
		
		//只有事业部itmall的ctm才能申请报销
		if(role.equals("CTM") && userLogin.getShiyebu().equals(shiyebu.getCommonValue())){

			PageBean res = baoxiaoShenpiBiz.searchCTMBaoxiao( bean.getCtm_code(),"","","", 1);
			this.request.setAttribute("pageBean", res);
			result = "success";
			return result;
		}else{
			 message = "只有ITMLL事业部的CTM才能执行该操作！";
			this.request.setAttribute("message", message);
			return "error";
		}
	}

}
